clear all
set more off
set matsize 10000
tempfile ubigeo temp

** PATHS

local lista trust_police trust_army trust_church trust_newsp trust_rtv trust_parties trust_regi trust_jury trust_parliament trust_jne trust_onpe
local controls schooling male rural native married head 

use mergedp, clear
merge 1:1 conglome vivienda hogar codperso year using `working'/ri
drop _merge

** LABELS
label var todoAT "Violence Exposure"

egen voted_bn = rowmax(voted_blank voted_null)
recode voted_bn voted_blank voted_null (. = 0) if voted == 0

******* Results
drop if vote_matter == .
local lista vote_matter voted voted_blank voted_null voted_bn partN dem_works dem_matters1 gov_demo1 gov_auto1

local r = 1
foreach var in `lista' {
	replace `var' = `var' * 100 if `r' != 6
	reghdfe `var' todoA todoT `controls', abs(ubigeo1993 ubigeonac1993 i.ubigeo1993#i.ubigeonac1993 i.age i.year i.provid#c.trend) vce(cluster ubigeonac1993) keepsin
	local betaA = _b[todoA]
	local betaT = _b[todoT]
	local pvA = 0
	local pvT = 0
	forvalues p = 1/1000 {
		qui reghdfe `var' todoA`p' todoT`p' `controls', abs(ubigeo1993 ubigeonac1993 i.ubigeo1993#i.ubigeonac1993 i.age i.year i.provid#c.trend) vce(cluster ubigeonac1993) keepsin
		if abs(_b[todoA`p']) > abs(`betaA') {
			local ++pvA
		}
		if abs(_b[todoT`p']) > abs(`betaT') {
			local ++pvT
		}
		di `pvA' "," `pvT' " / " `p'
	}
		local nA`r' = (round(`pvA'/1000, 0.0001)) 
		local nT`r' = (round(`pvT'/1000, 0.0001)) 
	local ++r
}

texdoc init Table_10a.tex, replace
tex & `nA1' & `nA2' & `nA3' & `nA4' & `nA5' & `nA6' & `nA7' & `nA8' & `nA9' \\
tex & `nT1' & `nT2' & `nT3' & `nT4' & `nT5' & `nT6' & `nT7' & `nT8' & `nT9' \\
